package view;

import java.awt.Color;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
 * this class is Graphic user interface of add item to catalog which extends AbstractGUI
 * @author Moran
 * 
 */
public class ItemToCatalogGUI extends AbstractGUI{
	private JButton back;//global to all panels
	private JLabel warningMas = null;
	private JPanel panel ;//panel 1 component
	private JButton AddBu = null;
	private JComboBox categoryCombo = null;
	private JComboBox typeCombo = null;
	private JComboBox itemCombo = null;
	private JLabel choosecategory = null;
	private JLabel choosetype = null;
	private JLabel chooseItem = null;
	
	/**
	 * constructor 
	 * this constructor add all the Label, Button,TextField to the Frame and panel 1
	 */
	public ItemToCatalogGUI(){
		super();
		back = new JButton("Back");
		back.setBounds(70, 244, 100, 22);
		panel = new JPanel();
		initPaternl();
	}
	/**
	 * Initialize panel 1
	 */
	public void initPaternl() {
		setTitle(" Item To Catalog ");
		setBounds(500, 200, 320, 330);
		setSize(361, 330);
		setContentPane(panel());	
	}
	/**
	 * add all the Label, Button,TextField to the panel 1
	 */
	public JPanel panel(){
		this.dispose();
		panel.setLayout(null);
		panel.add(getAddBu());
		panel.add(getCategoryCombo());
		panel.add(gettypeCombo());
		panel.add(getItemCombo());
		panel.add(getback());
		panel.add(getwarningMas());
		nowarningMas();
		panel.add(getchoosecategory());
		panel.add(getchoosetype());
		panel.add(getchooseItem());
		panel.setBackground(Color.lightGray);
		panel.setBounds(500, 200, 300, 250);
		setVisible(true);
		return panel;
	}
	public JComboBox gettypeCombo() {
		if(typeCombo == null){
			typeCombo = new JComboBox();
			typeCombo.setBounds(143, 59, 160, 20);
		}
		return typeCombo;
	}
	public String gettype() {
		if(typeCombo != null)
			return (String)(typeCombo.getSelectedItem());
		return null;
	}
	public JComboBox getCategoryCombo() {
		if(categoryCombo == null){
			categoryCombo = new JComboBox();
			categoryCombo.setBounds(143, 29, 160, 20);
		}
		return categoryCombo;
	}
	public String getCategory() {
		if(categoryCombo != null)
			return (String)(categoryCombo.getSelectedItem());
		return null;
	}
	public JComboBox getItemCombo() {
		if(itemCombo == null){
			itemCombo = new JComboBox();
			itemCombo.setBounds(143, 89, 160, 20);
		}
		return itemCombo;
	}
	/** 
	 * Getters and Setters of panel 1, Button,TextField 
	 */
	public JButton getAddBu() {
		if(AddBu == null){
			AddBu = new JButton("Add");
			AddBu.setBounds(164, 244, 100, 22);
		}		
		return AddBu;
	}
	public JButton getback() {
		if(back == null){
			back = new JButton("Cancel");
			back.setBounds(24, 254, 100, 22);
		}		
		return back;
	}
	public JLabel getchoosecategory() {
		if(choosecategory == null){
			choosecategory = new JLabel("choose category: ");
			choosecategory.setBounds(10, 30, 123, 22);
		}
		return choosecategory;
	}
	public JLabel getchoosetype() {
		if(choosetype == null){
			choosetype = new JLabel("choose type: ");
			choosetype.setBounds(10, 60, 123, 22);
		}
		return choosetype;
	}
	public JLabel getchooseItem() {
		if(chooseItem == null){
			chooseItem = new JLabel("choose Item: ");
			chooseItem.setBounds(10, 90, 123, 22);
		}
		return chooseItem;
	}
	public JLabel getwarningMas() {
		if(warningMas == null){
			warningMas = new JLabel("");
		
		warningMas.setBounds(10, 120, 250, 22);
		warningMas.setVisible(false);
		}
		return warningMas;
	}
	public void warningMas(String str) {
		warningMas.setText(str);
		warningMas.setVisible(true);
	}
	public void nowarningMas() {
		warningMas.setVisible(false);
	}
	
	public String getItem() {
		if(itemCombo != null)
			return (String)(itemCombo.getSelectedItem());
		return null;
	}
	
	/**
	 * add to back button ActionListener
	 * @param listener
	 */
	public void addbackActionListener(ActionListener listener){
		back.addActionListener(listener);
	}
	/**
	 * add to category Combo ActionListener
	 * @param listener
	 */
	public void addcategoryComboActionListener(ActionListener listener){
		categoryCombo.addActionListener(listener);
	}
	/**
	 * add to add button ActionListener
	 * @param listener
	 */
	public void addAddBottonActionListener(ActionListener listener){
		AddBu.addActionListener(listener);
	} 
}
